class Admin::FormsController < Admin::ResourceController

  skip_before_filter :verify_authenticity_token, :only => :create
  
  before_filter :config_global
  before_filter :config_new,    :only => [ :new, :create ]
  before_filter :config_edit,   :only => [ :edit, :update ]
  before_filter :assets_edit,   :only => [ :new, :create, :edit, :update ]
  
  only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
    :when => [ :designer, :admin ],
    :denied_url => { :controller => 'admin/pages', :action => 'index' },
    :denied_message => 'You must have designer privileges to perform this action.'
    
  private

    def config_global
      @inputs   ||= []
      @meta     ||= []
      @buttons  ||= []
      @parts    ||= []
      @popups   ||= []
    end
    
    def config_new
      @inputs   << 'title'
      
      @meta     << 'action'
      @meta     << 'redirect_to'
      
      @parts    << 'body'
      @parts    << 'config'
      @parts    << 'content'
      @parts    << 'secondary'
    end
    
    def config_edit
      @inputs   << 'title'
      
      @meta     << 'action'
      @meta     << 'redirect_to'
      
      @parts    << 'body'
      @parts    << 'config'
      @parts    << 'content'
      @parts    << 'secondary'
    end
    
    def assets_edit
      include_stylesheet 'admin/extensions/forms/edit'
    end
    
end